package o;

import android.text.TextUtils;
import android.view.View;
import android.widget.ListView;
import android.widget.ScrollView;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.appmarket.service.interactive.bean.InteractiveRecommResponse;
import java.lang.ref.WeakReference;

public class InteractiveRecommListenerImpl implements InteractiveRecommListener {

    class ListInterStoreCallBack implements IServerCallBack {
        private WeakReference<cia> ˊ;
        private String ˋ;
        private String ˎ;
        final /* synthetic */ InteractiveRecommListenerImpl ˏ;

        private ListInterStoreCallBack(InteractiveRecommListenerImpl o_ebl, String str, cia o_cia, String str2) {
            this.ˏ = o_ebl;
            this.ˎ = str;
            this.ˋ = str2;
            this.ˊ = new WeakReference(o_cia);
        }

        public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
        }

        public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
            if ((o_cvu instanceof ebe) && (responseBean instanceof InteractiveRecommResponse)) {
                ebe o_ebe = (ebe) o_cvu;
                InteractiveRecommResponse interactiveRecommResponse = (InteractiveRecommResponse) responseBean;
                if (this.ˊ == null) {
                    Logger.ˎ("InteractiveRecommListenerImpl", "ListInterStoreCallBack activity is recycled,weakProvider is null");
                } else if (System.currentTimeMillis() - o_ebe.ॱ() > 1000) {
                    Logger.ˎ("InteractiveRecommListenerImpl", "request time out,this data is invalid");
                } else {
                    cia o_cia = (cia) this.ˊ.get();
                    if (o_cia != null && interactiveRecommResponse.getRtnCode_() == 0 && interactiveRecommResponse.getResponseCode() == 0 && !CollectCheck.isEmpty(interactiveRecommResponse.ˊ()) && TextUtils.equals(this.ˎ, this.ˋ)) {
                        interactiveRecommResponse.ˋ(o_ebe.ˎ());
                        interactiveRecommResponse.ˊ(this.ˋ);
                        this.ˏ.ॱ(this.ˎ, interactiveRecommResponse, o_cia);
                    }
                }
            }
        }
    }

    public void ˎ(String str, BaseCardBean baseCardBean, int i) {
        if (i == 0 && eqp.ᐝ()) {
            ebe o_ebe = new ebe(baseCardBean.ॱॱ());
            o_ebe.ˏ(str);
            o_ebe.ॱ(baseCardBean.ॱˉ());
            ebi.ˊ().ˎ(o_ebe);
        }
    }

    private void ॱ(String str, InteractiveRecommResponse interactiveRecommResponse, cia o_cia) {
        if (o_cia != null) {
            BaseDistCardBean ˋ;
            long parseLong;
            long ˊ = ebi.ˊ().ˊ(str);
            if (ˊ > 0) {
                ˋ = ˋ(o_cia, ˊ);
                if (ˋ instanceof ebh) {
                    ((ebh) ˋ).ˊ(null);
                }
            }
            ˊ = -1;
            try {
                parseLong = Long.parseLong(interactiveRecommResponse.getLayoutId());
            } catch (NumberFormatException e) {
                Logger.ˋ("InteractiveRecommListenerImpl", "pare layoutid error," + e.toString());
                parseLong = ˊ;
            }
            ˋ = ˋ(o_cia, parseLong);
            if (ˋ instanceof ebh) {
                ebi.ˊ().ˋ(str, parseLong);
                ((ebh) ˋ).ˊ(interactiveRecommResponse);
                o_cia.ͺ();
            }
        }
    }

    private BaseDistCardBean ˋ(cia o_cia, long j) {
        if (o_cia == null || o_cia.ॱ(j) == null || CollectCheck.isEmpty(o_cia.ॱ(j).ˏ())) {
            return null;
        }
        CardBean cardBean = (CardBean) o_cia.ॱ(j).ˏ().get(0);
        return cardBean instanceof BaseDistCardBean ? (BaseDistCardBean) cardBean : null;
    }

    public void ˋ(View view, int i) {
        if (view instanceof ListView) {
            ((ListView) view).smoothScrollBy(i, 700);
        }
        if (view instanceof ScrollView) {
            ((ScrollView) view).smoothScrollBy(0, i);
        }
    }

    public void ॱ(String str, cia o_cia, cvt o_cvt) {
        if (o_cvt instanceof ebe) {
            ebe o_ebe = (ebe) o_cvt;
            if (TextUtils.equals(str, o_ebe.ˊ())) {
                o_ebe.ˊ(System.currentTimeMillis());
                cfw.ˎ(o_ebe, new o.InteractiveRecommListenerImpl.ListInterStoreCallBack(str, o_cia, o_ebe.ˊ()));
            }
        }
    }
}
